home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 May / may_2001.iso / intercd / root / Multimedia / ^DivX_Article / virtualdub / VirtualDub-source-1_4d / VBitmap.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-20  |  4.8 KB  |  152 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Copyright (C) 1998-2001 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #ifndef f_VIRTUALDUB_VBITMAP_H
  19. #define f_VIRTUALDUB_VBITMAP_H
  20.  
  21. #include <windows.h>
  22.  
  23. typedef unsigned long    Pixel;
  24. typedef unsigned long    Pixel32;
  25. typedef unsigned char    Pixel8;
  26. typedef long            PixCoord;
  27. typedef    long            PixDim;
  28. typedef    long            PixOffset;
  29.  
  30. #ifdef VDEXT_VIDEO_FILTER
  31. #define NOVTABLE __declspec(novtable)
  32. #else
  33. #define NOVTABLE
  34. #endif
  35.  
  36. class NOVTABLE VBitmap {
  37. public:
  38.     Pixel *            data;
  39.     Pixel *            palette;
  40.     int                depth;
  41.     PixCoord        w, h;
  42.     PixOffset        pitch;
  43.     PixOffset        modulo;
  44.     PixOffset        size;
  45.     PixOffset        offset;
  46.  
  47.     Pixel *Address(PixCoord x, PixCoord y) const {
  48.         return Addressi(x, h-y-1);
  49.     }
  50.  
  51.     Pixel *Addressi(PixCoord x, PixCoord y) const {
  52.         return (Pixel *)((char *)data + y*pitch + x*(depth>>3));
  53.     }
  54.  
  55.     Pixel *Address16(PixCoord x, PixCoord y) const {
  56.         return Address16i(x, h-y-1);
  57.     }
  58.  
  59.     Pixel *Address16i(PixCoord x, PixCoord y) const {
  60.         return (Pixel *)((char *)data + y*pitch + x*2);
  61.     }
  62.  
  63.     Pixel *Address32(PixCoord x, PixCoord y) const {
  64.         return Address32i(x, h-y-1);
  65.     }
  66.  
  67.     Pixel *Address32i(PixCoord x, PixCoord y) const {
  68.         return (Pixel *)((char *)data + y*pitch + x*sizeof(Pixel));
  69.     }
  70.  
  71.     PixOffset PitchAlign4() {
  72.         return ((w * depth + 31)/32)*4;
  73.     }
  74.  
  75.     PixOffset PitchAlign8() {
  76.         return ((w * depth + 63)/64)*8;
  77.     }
  78.  
  79.     PixOffset Modulo() {
  80.         return pitch - (w*depth+7)/8;
  81.     }
  82.  
  83.     PixOffset Size() {
  84.         return pitch*h;
  85.     }
  86.  
  87.     //////
  88.  
  89.     VBitmap() throw() {
  90. #ifdef VDEXT_VIDEO_FILTER
  91.         init();
  92. #endif
  93.     }
  94.     VBitmap(void *data, PixDim w, PixDim h, int depth) throw();
  95.     VBitmap(void *data, BITMAPINFOHEADER *) throw();
  96.  
  97. #ifdef VDEXT_VIDEO_FILTER
  98.     void init() throw() { *(void **)this = g_vtbls.pvtblVBitmap; }
  99. #endif
  100.  
  101.     virtual VBitmap& init(void *data, PixDim w, PixDim h, int depth) throw();
  102.     virtual VBitmap& init(void *data, BITMAPINFOHEADER *) throw();
  103.  
  104.     virtual void MakeBitmapHeader(BITMAPINFOHEADER *bih) const throw();
  105.  
  106.     virtual void AlignTo4() throw();
  107.     virtual void AlignTo8() throw();
  108.  
  109.     virtual void BitBlt(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy) const throw();
  110.     virtual void BitBltDither(PixCoord x2, PixCoord y2, const VBitmap *src, PixDim x1, PixDim y1, PixDim dx, PixDim dy, bool to565) const throw();
  111.     virtual void BitBlt565(PixCoord x2, PixCoord y2, const VBitmap *src, PixDim x1, PixDim y1, PixDim dx, PixDim dy) const throw();
  112.  
  113.     virtual bool BitBltXlat1(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const Pixel8 *tbl) const throw();
  114.     virtual bool BitBltXlat3(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const Pixel32 *tbl) const throw();
  115.  
  116.     virtual bool StretchBltNearestFast(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const VBitmap *src, double x2, double y2, double dx1, double dy1) const throw();
  117.  
  118.     virtual bool StretchBltBilinearFast(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const VBitmap *src, double x2, double y2, double dx1, double dy1) const throw();
  119.  
  120.     virtual bool RectFill(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, Pixel32 c) const throw();
  121.  
  122.     enum {
  123.         HISTO_LUMA,
  124.         HISTO_GRAY,
  125.         HISTO_RED,
  126.         HISTO_GREEN,
  127.         HISTO_BLUE,
  128.     };
  129.  
  130.     virtual bool Histogram(PixCoord x, PixCoord y, PixCoord dx, PixCoord dy, long *pHisto, int iHistoType) const throw();
  131.  
  132.     //// NEW AS OF VIRTUALDUB V1.2B
  133.  
  134.     virtual bool BitBltFromYUY2(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy) const throw();
  135.     virtual bool BitBltFromI420(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy) const throw();
  136.  
  137.     //// NEW AS OF VIRTUALDUB V1.4C
  138.  
  139.     virtual void MakeBitmapHeaderNoPadding(BITMAPINFOHEADER *bih) const throw();
  140.  
  141.     ///////////
  142.  
  143.     bool BitBltFromYUY2Fullscale(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy) const throw();
  144.  
  145. private:
  146.     bool dualrectclip(PixCoord& x2, PixCoord& y2, const VBitmap *src, PixCoord& x1, PixCoord& y1, PixDim& dx, PixDim& dy) const throw();
  147. };
  148.  
  149. #undef NOVTABLE
  150.  
  151. #endif
  152.